﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLT_Public;
using System.Data;

namespace QLT_Data
{
   public  class HoaDonBH_Data
    {
       KetNoiCSDL_Data kn = new KetNoiCSDL_Data();
       public DataTable LayDuLieu()
       {
           return kn.LayDuLieu("Load_tbl_HDBH");
       }
       public DataTable TaoBang(string sql)
       {
           return kn.taoBang(sql);
       }
       public int Insert_HoaDonBH(HoaDonBH_Public tenHD, HoaDonBH_Public ngayLap, HoaDonBH_Public maKH, HoaDonBH_Public maNV)
       {
           int Nparameter = 4;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@TenHD";
           value[0] = tenHD.TenHD;
           name[1] = "@Ngaylap";
           value[1] = ngayLap.NgayLap;
           name[2] = "@MaKH";
           value[2] = maKH.MaKH;
           name[3] = "@MaNV";
           value[3] = maNV.MaNV;
           return kn.update("insert_HoaDonBH", name, value, Nparameter);
       }
       public int Update_HoaDonBH(HoaDonBH_Public tenHD,HoaDonBH_Public maHDBH, HoaDonBH_Public ngayLap, HoaDonBH_Public maKH,  HoaDonBH_Public maNV)
       {
           int Nparameter = 5;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@TenHD";
           value[0] = tenHD.TenHD;
           name[1] = "@MaHDBH";
           value[1] = maHDBH.MaHDBH;
           name[2] = "@Ngaylap";
           value[2] = ngayLap.NgayLap;
           name[3] = "@MaKH";
           value[3] = maKH.MaKH;
           name[4] = "@MaNV";
           value[4] = maNV.MaNV;
           return kn.update("update_HoaDonBH", name, value, Nparameter);
       }
       public int Delete_HoaDonBH(HoaDonBH_Public maHDBH)
       {
           int Nparameter = 1;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@MaHDBH";
           value[0] = maHDBH.MaHDBH;
           return kn.update("delete_HoaDonBH", name, value, Nparameter);
       }
    }
}
